<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/4/13
  Time: 19:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page pageEncoding="UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
    <script type="text/javascript">
        function getCheckBoxValue() {
            var ids = $('input:checkbox[name="functionId"]:checked');
            var datas = '';

            for (var i = 0; i < ids.length; i++) {
                datas += ids[i].value + (i == ids.length - 1 ? '' : ',');
            }
            alert(datas);

            /*formElement.action='test.html';
            formElement.method='post';
            formElement.submit();*/
            with (datas) {
                action = '${pageContext.request.contextPath}/addFunctionToRole.do';
                method = 'post';
                submit();
            }
        }

    </script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>角色权限分配</strong></div>
    <div class="body-content">
        <form class="form-x" id="myform" action="addFunctionToRole.do">
            <input type="hidden" value="${role.roleId}" name="roleId">
            <div class="form-group">
                <div class="label">
                    <label>角色</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="${role.roleName}" name="" data-validate="用户Id"/>
                    <div class="tips"></div>

                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label>选择权限</label>
                </div>
                <div class="field">
                    <c:forEach var="function" items="${allFunction}"  >
                        <input type="checkbox" class="check-box" name="functionId" value="${function.functionId}"  <c:forEach items="${functionByRoleId}" var="functionByRoleI">
                            ${(functionByRoleI.function.functionName == function.functionName) || (function.functionFatherId=null )? 'checked':''}
                        </c:forEach> >${function.functionName}<br>
                    </c:forEach>
                    <div class="tips"></div>
                </div>

            </div>
<%--            <c:forEach items="${functionByRoleId}" var="functionByRoleI"><c:if test="${functionByRoleI.function.functionName eq function.functionName}" >checked</c:if> </c:forEach>--%>
            <%-- <div class="form-group">
                 <div class="label">
                     <label>功能</label>
                 </div>
                 <div class="field">
                     <select name="functionId" class="input w50">
                         <c:forEach items="${functionList}" var="functionList">
                             <option value="${functionList.functionId}">${functionList.functionName}</option>
                         </c:forEach>
                     </select>
                     <div class="tips"></div>
                 </div>
             </div>--%>


            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">

                    <input class="button bg-main icon-check-square-o" value="提交" type="submit"> </input>
                </div>
            </div>
        </form>
    </div>
</div>


</body>

</html>